package com.ttxz.sample

import androidx.room.Room
import com.ttxz.common.BaseApplication
import com.ttxz.common.utils.log.LogUtil
import com.ttxz.sample.db.MyDataBase


class MyApplication: BaseApplication() {
    companion object {
        var dbManager: MyDataBase? = null
    }
    override fun onCreate() {
        super.onCreate()
        initDB()
    }

    private fun initDB() {
        dbManager = Room.databaseBuilder(
            applicationContext,
            MyDataBase::class.java, "TTXZ_DB.db"
        )
            .allowMainThreadQueries()
            .build()
    }

    override val isLoggable: Boolean
        get() = BuildConfig.DEBUG

    override fun onCrash(errorStr: String?, originalThrowable: Throwable?) {
        LogUtil.e(originalThrowable, "[程序发生崩溃],$errorStr")
    }
}